﻿define(["angularAMD"], function (angularAMD) {
    angularAMD.service('B0252Service', ['$rootScope', '$filter', '$translate', 'config', 'MMWService', '$mdDialog',
        function ($rootScope, $filter, $translate, config, $MMWService, $mdDialog) {
            this.init = function (options) {
                $mdDialog.dialog(
                'module/moduleB/program/B02/B0252/B0252.html', function (dialog) {
                    return {
                        css_url: 'module/moduleB/program/B02/B0252/B0252.css',
                        countdown_label: '',
                        LOTNO: '',
                        AccessoryNo: '',
                        LoadTools: '',
                        locatorNo: '',
                        templocatorNo: '',
                        PrepareTime: '',
                        index: 0,
                        maxPage: 1,
                        thisPage: 1,
                        back: function () {
                            dialog.hide();
                        },
                        confirm: function () {

                        },
                        nextData: function () {
                            if (dialog.thisPage + 1 <= dialog.maxPage)
                            {
                                dialog.index++;
                                dialog.thisPage++;
                                dialog.setAccessoryData(dialog.index);
                            }
                        },
                        lastData: function () {
                            if(dialog.thisPage > 1)
                            {
                                dialog.index--;
                                dialog.thisPage--;
                                dialog.setAccessoryData(dialog.index);
                            }

                        },
                        beforeShown: function () {
                            dialog.index = 0;
                            dialog.maxPage = options.AccessoryData.length;
                            dialog.thisPage = 1;
                            dialog.AccessoryList = options.AccessoryData;
                            dialog.setAccessoryData(dialog.index);                            
                        },
                        setAccessoryData: function (index) {
                            dialog.AccessoryData = dialog.AccessoryList[index];
                            dialog.countdown_label = $filter('translate')('B0252.countdown', { countdown: dialog.AccessoryData.countdown });
                            dialog.PrepareTime = $filter('translate')('B0252.PrepareTime', { PrepareTime: dialog.AccessoryData.PrepareTime });
                        }
                    };
                });

                
            };

            
        }]);
});

